﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SDT.Site.ViewModels.BannerViewModels>" %>
<% var idBanner = Model.MenuID.ToString() + Model.PositionID.ToString();%>
<div id="ftcBanner<%=idBanner %>">
<%if(Model.Banners!=null && Model.Banners.Count>0){
      var shareYN = Model.Banners[0].BannerMenuMaps[0].Position.ShareYN.HasValue ? Model.Banners[0].BannerMenuMaps[0].Position.ShareYN.Value : false;     %>
 <%if (shareYN == false)
  {
      foreach (var b in Model.Banners)
      {
          if (b.ImagePath != null && b.ImagePath != string.Empty)
          {
              string imgPath = (b.ImagePath != null && b.ImagePath != string.Empty) ? SDT.Lib.Common.Utils.GenThumbnail(b.ID, Model.Width, Model.Height, b.ImagePath, Model.ImagePath, Model.ImageUrl) : SDT.Lib.Common.Globals.DefaultLogo;
              if (imgPath != string.Empty)
              {
            %>
            <div class="banner_item" >
                <a href="<%=b.UrlClick %>" target="_blank" onclick="BannerClick(<%=b.ID %>);">
                    <img src="<%=imgPath %>" title="<%=b.Name %>" alt="<%=b.Name %>" width="<%=Model.Width %>" style="overflow:hidden"/>
                </a>
            </div>
         <%}
          }
          else if (b.FlashPath != null)
          {
              var flashPath = Model.FlashUrl + b.ID + "_" + b.FlashPath;
          %>
      
              <div class="banner_item" onclick="BannerClick(<%=b.ID %>);">
                  <embed width="<%=Model.Width %>" height="<%=Model.Height %>" src="<%=flashPath %>?clicktag=<%=b.UrlClick %>" quality="high" 
                    pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" 
                    type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" menu="false" scale="exactfit">
                  </embed>
              </div>
      
            <%} %>
    <%}
  }
  else {
      foreach (var b in Model.Banners)
      {
          if (b.ImagePath != null && b.ImagePath != string.Empty)
          {
              string imgPath = (b.ImagePath != null && b.ImagePath != string.Empty) ? SDT.Lib.Common.Utils.GenThumbnail(b.ID, Model.Width, Model.Height, b.ImagePath, Model.ImagePath, Model.ImageUrl) : SDT.Lib.Common.Globals.DefaultLogo;
              if (imgPath != string.Empty)
              {
            %>
            <div class="banner_item">
                <a href="<%=b.UrlClick %>" target="_blank" onclick="BannerClick(<%=b.ID %>);">
                    <img src="<%=imgPath %>" title="<%=b.Name %>" alt="<%=b.Name %>" width="<%=Model.Width %>" style="overflow:hidden"/>
                </a>
            </div>
         <%}
          }
          else if (b.FlashPath != null)
          {
              var flashPath = Model.FlashUrl + b.ID + "_" + b.FlashPath;
          %>
      
              <div class="banner_item" onclick="BannerClick(<%=b.ID %>);">
                  <embed width="<%=Model.Width %>" height="<%=Model.Height %>" src="<%=flashPath %>?clicktag=<%=b.UrlClick %>" quality="high" 
                    pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" 
                    type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" menu="false" scale="exactfit">
                  </embed>
              </div>
      
            <%} %>
      <%} %>
      <script type="text/javascript">
          var BannerRightBottom = 1;
          function Random_BannerRightBottom() {
              var _Arr = document.getElementById("ftcBanner<%=idBanner %>").getElementsByTagName("div");
              for (i = 0; i <= _Arr.length - 1; i++)
              { _Arr[i].className = 'bannerHide'; }
              _Arr[BannerRightBottom - 1].className = 'bannerShow';
              window.setTimeout("Random_BannerRightBottom()", 25000);
              BannerRightBottom = BannerRightBottom + 1;
              if (BannerRightBottom > _Arr.length) BannerRightBottom = 1;
          }
          Random_BannerRightBottom();
    </script>
  <%}
} %>
</div>

